<?php session_start();
error_reporting(E_ALL);
if(!isset($_SESSION['loggin']))
{
	die('You did not login, Please login first!');
}
?>
<html><!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>DrinkDelivery</title>
<!-- InstanceEndEditable -->
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="login">
<img src="image/logo.jpg" width="100" height="30" align="middle">
 <p> <font size="+2" color="#FFFFFF"><a href="CU.html">                                           Contact Us</a></font></p>
<a href="logout.php"><img src="image/logout.png" align="right"></a>
<a href="login.php"><img src="image/login.png" align="right"></a> 
</div>
<div id="header">
<ul>
  <li></li>
<li><a href="store.php"><img src="image/m2.jpg" width="200" height="200"></a></li>
<li><a href="member.php"><img src="image/m3.jpg" width="200" height="200"></a></li>
<li><a href="category.php"><img src="image/m4.jpg" width="200" height="200"></a></li>
</ul>
</div>
<br/>
<div id="content">
<!-- InstanceBeginEditable name="content" -->
<div id="member">
<p>
<h1 align="center">welcome to change your detail, please be careful!</h1>
    <form action="change.php" method="post">  
    <table border="1" cellpadding="10px" cellspacing="0" align="center">
    <tr>
    <th>Password</th>
    <td>
    <input type="password" name="passwd" size="40" /> </td>
    </tr>
    <tr>
    <th>Password Again</th>
    <td>
    <input type="password" name="passwd2" size="40" /> </td>
    </tr>
    <tr>
    <th>Telephone</th>
    <td>
    <input type="text" name="phone" size="40" /> </td>
    </tr>
    <tr>
    <th>Address</th>
    <td>
    <input type="text" name="addre" size="40" /> </td>
    </tr>
    <th>
    <input type="submit" name="submit" value="Submit" />
    <input type="button" value="Reset"/></th>
    <tr></tr>
    </table>
    </form>    
    <?php
	if ( isset($_REQUEST['submit']) ) 
{
		$connection = mysql_connect("localhost", "root", "");
		if ( !$connection ) {
			die('Could not connect to localhost.');	
							}

		$db = mysql_select_db("test", $connection);
		if ( !$db) {
			die ('Could not find database test.');	
					}
			if($_POST['passwd']!=$_POST['passwd2'])
	{
		die('password are not the same, please try again');
	}
	
	$name_qry="SELECT name FROM users WHERE name =  '".$_SESSION['username']."'";
	
	$name_check = mysql_query($name_qry,$connection);
	
	$row = mysql_fetch_array($name_check);
	
	$name_checkk = mysql_num_rows($name_check);
		
	
	$sqlstra ="update users set address='".$_POST['addre']."'  WHERE name =  '".$_SESSION['username']."'";
	$sqlstrp ="update users set phone='".$_POST['phone']."'  WHERE name =  '".$_SESSION['username']."'";
	$sqlstrw ="update users set password='".$_POST['passwd']."'  WHERE name =  '".$_SESSION['username']."'";
	$insta = mysql_query($sqlstra);	
	if (!$insta)
 	 {
  		die('Error: ' . mysql_error());
 	 }
	$instp = mysql_query($sqlstrp);
	
	if (!$instp)
 	 {
  		die('Error: ' . mysql_error());
 	 }
	$instaw = mysql_query($sqlstrw);	
	if (!$insta)
 	 {
  		die('Error: ' . mysql_error());
 	 }
	mysql_close($connection);	
}
?></p>
</div>
<div id="memberfunction">
<img src="id/xiaohei.jpg" width="300"
height="300">
<br/><a href="bill.php"><img src="image/bill.jpg" width="100" height="50" align="middle"></a>
<a href="member.php"><img src="image/detail.jpg" width="100" height="50" align="right"></a>
<br /><a href="chart.php"><img src="image/chat.jpg" width="100" height="50" align="middle"></a>
<a href="feedback.php"><img src="image/feedback.jpg" width="100" height="50" align="right"></a>
</div>
<?php mysql_close($connection); ?>
<!-- InstanceEndEditable -->
</div>
<a href="index.php">z</a> </div>
</body>
<!-- InstanceEnd --></html>
